package com.drcoffee.drcoffeemall.controller;

import com.drcoffee.drcoffeemall.entry.PayVoucher;
import com.drcoffee.drcoffeemall.entry.Result;
import com.drcoffee.drcoffeemall.service.OrderService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.*;

@RestController
@RequestMapping("/order")
public class OrderContrcller {
    final
    private OrderService orderService;

    public OrderContrcller(OrderService orderService) {
        this.orderService = orderService;
    }

    @GetMapping("/processAnOrder")
    public ResponseEntity<Object> processAnOrder(@RequestHeader String token, @RequestParam String order_code) {
        return orderService.processAnOrder(token, order_code);
    }


    @PostMapping("/getOrderList")
    public Object getOrderList(@RequestBody Map<String, Object> paramMap) {
        return orderService.getOrderList(paramMap);
    }


    @PostMapping("/getOrderParts")
    public ResponseEntity<Object> getOrderParts(@RequestBody Map<String, Object> paramMap) {
        return orderService.getOrderParts(paramMap);
    }


    /*
     * 查询出未处理的订单
     * */
    @PostMapping("/getNotThrowOrdderHead")
    public ResponseEntity<Object> getNotThrowOrdderHead(@RequestBody Map<String, Object> paramMap) {
        return orderService.getNotThrowOrdderHead(paramMap);
    }

    @PostMapping("/getNotThrowOrdderDetail")
    public ResponseEntity<Object> getNotThrowOrdderDetail(@RequestBody Map<String, Object> paramMap) {
        return orderService.getNotThrowOrdderDetail(paramMap);
    }


    /*
     * 查询发货订单
     * */
    @PostMapping("/getTransportOrder")
    ResponseEntity<Object> getTransportOrder(@RequestBody Map<String, Object> paramMap) {
        return orderService.getTransportOrder(paramMap);
    }

    /*
     * 订单发货状态
     * */
    @GetMapping("/setTransportCode")
    public Result setTransportCode(@RequestParam String order_code, String transport_code) {
        return orderService.setTransportCode(order_code, transport_code);
    }


    /*
     * 查询汇款凭证
     * */
    @PostMapping("/getVoucherData")
    public ResponseEntity<Object> getVoucherData(@RequestBody Map<String, Object> paramMap) {
        return orderService.getVoucherData(paramMap);
    }

    /*
     * 审核汇款凭证
     * */
    @PostMapping("/setVoucherY")
    public Result setVoucherY(@RequestBody PayVoucher voucher) {
        return orderService.setVoucherY(voucher);
    }


    @GetMapping("/getOrderByCode")
    public ResponseEntity<Object> getOrderByCode(@RequestParam String order_code) {
        return orderService.getOrderByCode(order_code);
    }


    /*
     * 查询交易记录
     * */
    @PostMapping("/getAllTrade")
    public ResponseEntity<Object> getAllTrade(@RequestBody Map<String, Object> paramMap) {
        return orderService.getAllTrade(paramMap);
    }


    @PostMapping("/setOrderDisplace")
    public ResponseEntity<Object> setOrderDisplace(@RequestBody Map<String, Object> paramMap) {
        return orderService.setOrderDisplace(paramMap);
    }

    @PostMapping("/setOrderDisplace1")
    public ResponseEntity<Object> setOrderDisplace1(@RequestBody Map<String, Object> paramMap) {
        return orderService.setOrderDisplace1(paramMap);
    }

    @PostMapping("/throwToOcm")
    public ResponseEntity<Object> throwToOcm(@RequestBody Map<String, Object> paramMap) throws Exception {
        return orderService.throwToOcm(paramMap);
    }

    @GetMapping("/tRecord")
    public Result tRecord() {
        return orderService.tRecord();
    }

}
